home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / HOSETUP.CMD < prev    next >
OS/2 REXX Batch file  |  1991-07-10  |  14KB  |  488 lines

  1.     SET TTHRU OFF        ; Must be 1st line to suppress typethrough
  2.     LEGEND "HOST Setup ver 1.0"
  3. ;****    TRACE ON        ; Debugging
  4. ;
  5. ; ----- COM-AND HOST setup script
  6. ;    Commenced: 11/90 R.McG
  7. ; -----------------------------------------------------------------------
  8. ;    Purpose:
  9. ;       This script, named HOSETUP.CMD, is executed to setup the HOST
  10. ;    script (version 1.1).  Setup 1) identifies the port and modem
  11. ;    control values, 2) identifies the ID/passwords to be used.
  12. ; -----------------------------------------------------------------------
  13. ;
  14. ;    Establish a DWINDOW, and change the text display to window default.
  15. ;    .. Save the previous text display attribute, for restoration later.
  16. ;
  17.     DWIND 1,2 22,78     ; Establish scrolling region
  18.     N99 = "_TEXT"           ; Save original text attr
  19.     SET TEXT "_DEFA"        ; Set text attr
  20.     SET FLAG(9) OFF     ; Note if we did any saves
  21. ;
  22. ;    Perform tasks
  23. ;
  24.     GOSUB Init        ; Setup initial values
  25.     GOSUB Main        ; Paint main screen
  26. ;
  27. ;    Exit the script
  28. ;
  29. Escape:
  30. Exit:
  31.     SET TEXT N99        ; Reset text attr finally
  32.     DWINDOW CLEAR        ; Clear any scrolling region
  33.     CLEAR            ; Clear entire text window
  34.     EXIT
  35. ; -----------------------------------------------------------------------
  36. ; ----- Subroutine: Init ->  Set initial values from HOSTDAT
  37. ;    .. NOTE: S29 returns the file name to use for writes to HOSTDAT
  38. ;
  39. Init:
  40.     S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
  41.     S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M"  ; Standard MINIT for HOST
  42.     S22 = "****"            ; Default logon password
  43.     S23 = "xxxx"            ; Default DOS mode password
  44.     S24 = ""                ; Default Drop-to-DOS command
  45. ;
  46. ;    Replace above values from HOSTDAT if that script exists
  47. ;
  48.     IF ISSC "HOSTDAT"       ; If file exists on dft subdir or COM-AND=
  49.        FCALL "HOSTDAT"      ; .. environment var, execute it
  50.        ENDIF
  51.     RETURN            ; Done init
  52. ; -----------------------------------------------------------------------
  53. ; ----- Subroutine: Save -> Save values in HOSTDAT
  54. ;    .. HOSTDAT is placed in dft subdir; create file if need be
  55. ;
  56. Save:
  57.     ;
  58.     ; Construct a file name on the appropriate directory
  59.     ;
  60.     S1 = ""                 ; Initialize file name string
  61.     IF NOT ISFIL "HOSTDAT"  ; If not on current subdir
  62.        ENVIRON S1 "COM-AND="; Look for COM-AND= environment var
  63.        IF FOUND        ; If environment variable found
  64.           LENGTH S1 N0    ; Get its length
  65.           N0 = N0-1     ; Point to last char in string
  66.           IF not STRCMP S1(n0:n0) "\"
  67.          N0 = N0+1    ; Point after last char
  68.          CONCAT S1(n0) "\"
  69.          ENDIF
  70.           ENDIF
  71.        ENDIF
  72.     S1 = S1&"HOSTDAT"        ; Add the necessary file name
  73.     ;
  74.     ; Open the file, write the file, and close it
  75.     ;
  76.     FOPENO S1 TEXT        ; Open the file name so constructed
  77.     IF NOT SUCCESS
  78.        S0 = "Error opening HOSTDAT file: "*S1
  79.        GOSUB Error        ; Report
  80.        RETURN        ; And we're done
  81.        ENDIF
  82.        ;
  83.        ; Write values we have as of now
  84.        ;
  85.     WRITE "; --- HOST initialization !" ; Write initial comments
  86.     WRITE ";     Updated "*"_DATE"*", at "*"_TIME"*"!"
  87.     WRITE ";!"                         ; Write initial comments
  88.  
  89.     WRITE "S20=`""*S20&"`"!"    ; Write port and speed
  90.     S0 = S21        ; Copy control string
  91.     PRESERVE S0        ; Make it printable
  92.     WRITE "S21=`""*S0&"`"!" ; Write modem control string
  93.     WRITE "S22=`""*S22&"`"!"; Write logon password
  94.     WRITE "S23=`""*S23&"`"!"; Write DOSmode password
  95.     S0 =  "S24=`""*S24&"`"" ; Setup Drop-to-DOS command
  96.     PRESERVE S0        ; Preserve carets, grave, and bangs
  97.     WRITE S0        ; Write DOSmode password
  98.     WRITE "!"               ; Write terminating cr for drop-to-dos line
  99.     WRITE "FRETURN!^Z "     ; Write end of file
  100.        ;
  101.        ; Close the file and we're done
  102.        ;
  103.     SET FLAG(9) ON        ; Note we did ONE save
  104.     FCLOSEO         ; Close the file
  105.     RETURN            ; And we're done
  106. ; -----------------------------------------------------------------------
  107. ; ----- Error:    Open a window, display a message, and wait for keypress
  108. ;    S0 passes the error message
  109. ;
  110. Error:
  111.     WOPEN 10,10,12,70 (cont) Err_Esc
  112.     ATSAY 10,12 (cont) " Error "
  113.     ATSAY 11,12 (cont) S0(0:55); Max msg width 55 chars
  114.     ATSAY 12,26 (cont) " Press any key to continue "
  115.     ;
  116.     ;    Wait a keypress
  117.     ;
  118.     KEYGET S0        ; Wait for any key
  119.     WCLOSE
  120. Err_Esc:
  121.     RETURN
  122. ; -----------------------------------------------------------------------
  123. ; ----- Subroutine: Main ->  main menu
  124. ;
  125. Main:
  126.     WOPEN 0,0 23,79 (defa) Main_ESC
  127.     ATSAY 0,2 (defa)   " HOST Setup "
  128.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  129. Main100:
  130.     CLEAR            ; Clear window
  131.     LOCATE 2,2
  132.     MESS " 1) Identify modem values"
  133.     MESS " 2) Identify passwords"
  134.     MESS " 3) Define DROP-to-DOS command"
  135.     MESS "_______________________________________"
  136.     MESS " "
  137.     MESS "    Port and speed  is: "*S20
  138.     S0 = S21        ; Copy control string
  139.     PRESERVE S0        ; Make it printable
  140.     MESS "    Modem control   is: "*S0
  141.     MESS "    Logon password  is: "*S22
  142.     MESS "    DOS password    is: "*S23
  143.     MESS "    Drop to DOS command is: "
  144.     S0 = S24
  145.     PRESERVE S0        ; Make it printable
  146.     MESS "    "*S0
  147.     MESS "_______________________________________"
  148.     MESS " "
  149.     MESS "Select item (carriage return = exit): "
  150. ;
  151. ;    Wait for a keypress
  152. ;
  153.     GET S0 1        ; Wait for it
  154.     SWITCH S0        ; Act according to keyget
  155.       CASE "1"
  156.            GOSUB Modem
  157.            ENDCASE
  158.       CASE "2"
  159.            GOSUB Password
  160.            ENDCASE
  161.       CASE "3"
  162.            GOSUB DropDOS
  163.            ENDCASE
  164.       CASE "_NULL"          ; c/r alone is exit
  165.            WCLOSE        ; Close window...
  166.            RETURN        ; Leave Main routine
  167.            ENDCASE
  168.       DEFAULT        ; None of the above
  169.            SOUND 100,100    ; Bronx cheer
  170.            ENDCASE
  171.       ENDSWITCH
  172.     GOTO Main100        ; Repaint screen and ask again
  173. ; -----------------------------------------------------------------------
  174. ; ----- Subroutine: Modem ->  modem values
  175. ;
  176. Modem:
  177.     WOPEN 0,0 23,79 (defa) Main_ESC
  178.     ATSAY 0,2 (defa)   " HOST Modem "
  179.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  180. MODE100:
  181.     CLEAR            ; Clear window
  182.     LOCATE 2,2
  183.     MESS " 1) Identify modem port"
  184.     MESS " 2) Identify modem speed"
  185.     MESS " 3) Identify modem control string"
  186.     MESS "_______________________________________"
  187.     MESS " "
  188.     MESS "    Port and speed  is: "*S20
  189.     S0 = S21        ; Copy control string
  190.     PRESERVE S0        ; Make it printable
  191.     MESS "    Modem control   is: "*S0
  192.     MESS "_______________________________________"
  193.     MESS " "
  194.     MESS "Select item (carriage return = previous): "
  195. ;
  196. ;    Wait for a keypress
  197. ;
  198.     GET S0 1        ; Wait for it
  199.     SWITCH S0        ; Act according to keyget
  200.       CASE "1"
  201.            GOSUB Modem_Port
  202.            ENDCASE
  203.       CASE "2"
  204.            GOSUB Modem_Speed
  205.            ENDCASE
  206.       CASE "3"
  207.            GOSUB Modem_Control
  208.            ENDCASE
  209.       CASE "_NULL"          ; c/r alone is exit
  210.            WCLOSE        ; Close window...
  211.            RETURN        ; Leave Main routine
  212.            ENDCASE
  213.       DEFAULT        ; None of the above
  214.            SOUND 100,100    ; Bronx cheer
  215.            ENDCASE
  216.       ENDSWITCH
  217.     GOTO MODE100        ; Repaint screen and ask again
  218. ;
  219. ;    Escape during main
  220. ;
  221. Main_Esc:
  222.     S0 = ""                 ; Blank entry
  223.     RETURN            ; And execute it
  224. ;
  225. ; ----- Subroutine: Modem_port -> Set default modem port to use
  226. ;
  227. Modem_Port:
  228.     WOPEN 0,0 23,79 (defa) Main_ESC
  229.     ATSAY 0,2 (defa)   " HOST Port "
  230.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  231.     LOCATE 2,2
  232.  
  233.     MESS "The HOST is currently directed to run on the port: "*S20(0:3)
  234.     MESS " "
  235.     MESS "The HOST may use any port COM1 through COM4.  If you wish to use a port"
  236.     MESS "other than the above, enter it here."
  237.     MESS " "
  238.     MESS "Port (carriage rtn alone accepts): "
  239. ;
  240. ;    Wait for entry, and interpret
  241. ;
  242.     S0 = "    "             ; Default value
  243.     GET S0 4        ; Wait for a char
  244.     IF NULL S0 GOTO MOPOEND ; Nothing entered
  245.     IF NOT FIND S0(0:2) "com" GOTO MOPOERR
  246.     IF S0(3) LT 1 or S0(3) GT 4 GOTO MOPOERR
  247. ;
  248. ;    Save the value
  249. ;
  250.     S20(0:3) = S0        ; Set new value
  251.     GOSUB Save        ; Save the new value
  252. ;
  253. ;    End of window
  254. ;
  255. MOPOEND:
  256.     WCLOSE
  257.     RETURN
  258. ;
  259. ;    Error in input string
  260. ;
  261. MOPOERR:
  262.     SOUND 100,100        ; Bronx cheer
  263.     GOTO Modem_Port     ; And try again
  264. ;
  265. ; ----- Subroutine: Modem_Speed -> Set default modem speed to use
  266. ;
  267. Modem_Speed:
  268.     WOPEN 0,0 23,79 (defa) Main_Esc
  269.     ATSAY 0,2 (defa)   " HOST Speed "